package com.usaas.search.component;

import com.usaas.search.dto.PlatUserDto;

public class UserContextHolder {
    private static final ThreadLocal<PlatUserDto> userInfoHolder = new ThreadLocal<>();
    private static final ThreadLocal<String> tokenHolder = new ThreadLocal<>();

    public static void set(PlatUserDto user, String token) {
        userInfoHolder.set(user);
        tokenHolder.set(token);
    }

    public static PlatUserDto get() {
        return userInfoHolder.get();
    }

    public static String getToken() {
        return tokenHolder.get();
    }

    public static void clear() {
        userInfoHolder.remove();
        tokenHolder.remove();
    }
}
